package com.zmzncs.lmtc.module.customer.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zmzncs.lmtc.common.pojo.Rest;
import com.zmzncs.lmtc.common.util.JsonUtil;
import com.zmzncs.lmtc.common.util.RestUtil;
import com.zmzncs.lmtc.module.customer.pojo.card_record.CardRecordDTO;
import com.zmzncs.lmtc.module.customer.pojo.card_record.CardRecordTableVO;
import com.zmzncs.lmtc.module.customer.pojo.cust_info.CustInfoDTO;
import com.zmzncs.lmtc.module.customer.pojo.cust_info.CustInfoGrantTicketVO;
import com.zmzncs.lmtc.module.customer.service.CustInfoService;
import com.zmzncs.lmtc.module.promotion.pojo.duration_rule.DurationRuleTableVO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * <p>
 * 客户-客户信息 前端控制器
 * </p>
 *
 * @author 任建波
 * @since 2020-10-12
 */
@RestController
@RequestMapping("/customer/cust-info")
public class CustInfoController {

    @Autowired
    private CustInfoService custInfoService;

    @ApiOperation(value = "手机号/昵称查询会员信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
            @ApiImplicitParam(paramType = "query", name = "info", value = "手机号/昵称"),
    })
    @GetMapping(value = "getCustInfoByPhoneOrName")
    public Rest<List<CustInfoGrantTicketVO>> getCustInfoByPhoneOrName(@NotNull String info) {
        List<CustInfoDTO> custInfoDTOS = custInfoService.getCustInfoByPhoneOrName(info);
        List<CustInfoGrantTicketVO> infoList = JsonUtil.listTransform(custInfoDTOS, CustInfoGrantTicketVO.class);
        return RestUtil.success(infoList);
    }
}

